<template>
	<view>
		<view class="wrap">
			<view class="">
				<u-dropdown ref="uDropdown">
					<u-dropdown-item :title="title1" :options="options1" v-model="selCla" @change="changeCLass($event)">
					</u-dropdown-item>
					<u-dropdown-item v-model="value1" title="课程" :options="dataList" @change="change"></u-dropdown-item>
					<!-- <u-dropdown-item title="课程">
						<view class="slot-content">
							<view class="item-box">
								<view class="item" :class="[item.active ? 'active' : '']" @tap="tagClick(index)"
									v-for="(item, index) in dataList" :key="index">
									{{item.label}}
								</view>
							</view>
							<u-button type="primary" @click="closeDropdown">确定</u-button>
						</view>
					</u-dropdown-item> -->
				</u-dropdown>
			</view>
			<view v-for="(item,index) in signList" :key="index">
				<u-card :title="item.title" padding="30" margin="26rpx">
			
					<view class="" slot="body">
						<u-parse class="u-body-item-title u-line-2" :html="'姓名： '+item.studentName"></u-parse>
						<u-parse v-show="item.signInAddress!=null"
							class="u-body-item-title u-line-2">签到地址：{{ item.signInAddress }}</u-parse>
					</view>
			
					<view slot="foot" style="display: flex;align-items: center;justify-content: space-between;">
						<view  class="u-body-item-title u-line-2" v-if="item.status">签到状态：<label  style="color: rgb(41, 121, 255);">已签到</label>
						<!-- <view  class="u-body-item-title u-line-2">签到时间：<label v-else-if="item.status" style="color: rgb(41, 121, 255);">已签到</label> -->
						<view>签到时间：<label  style="color: rgb(41, 121, 255);">{{item.signInTime}}</label></view>
						</view>
						<view v-else style="color: red;">未签到</view>
					</view>
				</u-card>
			
			</view>
			<!-- <view class="u-tabs-box">
				<u-tabs-swiper activeColor="#f29100" ref="tabs" :list="list" :current="current" @change="change" :is-scroll="false" swiperWidth="750"></u-tabs-swiper>
			</view> -->
			<!-- <view v-if="dataList.length>0">
				<uni-card :title="item.title" :extra="item.addrs" v-for="(item,index) in dataList" :key="index"
					@click="signDetails(item)">
					<text class="uni-body" v-html="item.content" style="line-height: 60px;"></text>
					<uni-list>
						<uni-list-item :title="item.attendClassTime"></uni-list-item>
						<uni-list-item :title="item.quittingTime"></uni-list-item>
					</uni-list>
					
				</uni-card>
			</view> -->
			<!-- <view v-else>
				<view style="text-align: center;justify-content: center;align-content: center;">
					<u-empty text="" mode="data"></u-empty>
				</view>

			</view> -->

		</view>

	</view>
</template>

<script>
	import {
		getTeacherCourseListByClassId,
		delByid,
		getClassInfoByTeacherId
	} from '@/api/jz/course/api.js'
	import {
		getWorkInfoList,
		delWorkJob,
		editWorkJob
	} from '@/api/jz/class/class.js';
	import {
		getAllSign
	} from '@/api/jz/sign/info.js'
	export default {
		data() {
			return {
				content: "确认删除吗?",
				dataList: [

				],
				signList:[],
				value1: 0,
				options1: [],
				title1: "班级",
				selCla: "",
				show: false,
				show2: false,
				list: [{
						name: '待付款'
					},
					{
						name: '待发货'
					},
					{
						name: '待收货'
					},
					{
						name: '待评价',
						count: 12
					}
				],
				list: [{
						label: '琪花瑶草',
						active: true,
					},
					{
						label: '清词丽句',
						active: false,
					},
					{
						label: '宛转蛾眉',
						active: false,
					},
					{
						label: '煦色韶光',
						active: false,
					},
					{
						label: '鱼沉雁落',
						active: false,
					},
					{
						label: '章台杨柳',
						active: false,
					},
					{
						label: '霞光万道',
						active: false,
					}
				],
				pointList: [],
				current: 0,
				swiperCurrent: 0,
				tabsHeight: 0,
				dx: 0,
				loadStatus: ['loadmore', 'loadmore', 'loadmore', 'loadmore'],
				courseId: "",
				defaultDate: null,
				index: null
			};
		},
		onLoad() {

		},
		mounted() {
			var date = new Date();
			var y = date.getFullYear();
			var m = date.getMonth() + 1;
			var d = date.getDate();
			this.defaultDate = y + "-" + m + "-" + d;

			this.getClassInfoByTeacherId();

		},
		computed: {

		},
		methods: {
			closeDropdown() {
				this.$refs.uDropdown.close();
			},
			tagClick(index) {
				this.dataList[index].active = !this.dataList[index].active;
			},
			signDetails(val) {
				const params = encodeURIComponent(JSON.stringify(val))
				this.$tab.navigateTo("/pages/signIn/signInIList/signInDetail?data=" + params)
			},
			async getClassInfoByTeacherId() {
				this.options1 = []
				let res = await getClassInfoByTeacherId();
				for (var i = 0; i < res.length; i++) {
					this.options1.push({
						label: res[i].className,
						value: res[i].id
					})
					this.title1 = this.options1[0].label
					this.selCla = this.options1[0].value
					this.getList();
				}

			},
			async getList(id) {
				let data = {
					type: 1,
					classId: this.selCla

				}
				await getTeacherCourseListByClassId(data).then((res) => {
					if (res.code == 200) {
						for (var i = 0; i < res.rows.length; i++) {
							res.rows[i].attendClassTime = "上课时间：" + res.rows[i].attendClassTime;
							res.rows[i].quittingTime = "下课时间：" + res.rows[i].quittingTime;
							res.rows[i].label = res.rows[i].title
							if (res.rows[i].professorName) {
								res.rows[i].title = res.rows[i].title + "(" + res.rows[i].professorName + ")"
							}

							res.rows[i].value = res.rows[i].id

						}
						this.dataList = res.rows;
					}
				})


			},
			del(row) {
				this.courseId = row.id
				this.show = true;
			},

			confirm() {
				delByid(this.courseId).then((res) => {
					if (res.code == 200) {
						this.getList();
					}
				})
			},



			async changeDate(e) {
				if (e.month < 10) {
					e.month = "0" + e.month
				}
				if (e.dayday < 10) {
					e.day = "0" + e.day
				}
				let data = {
					type: 2,
					classId: this.selCla,
					attendClassTime: e.year + "-" + e.month + "-" + e.day + " 00:00:00"
				}

				await getTeacherCourseListByClassId(data).then((res) => {
					if (res.code == 200) {
						for (var i = 0; i < res.rows.length; i++) {
							res.rows[i].attendClassTime = "上课时间：" + res.rows[i].attendClassTime;
							res.rows[i].quittingTime = "下课时间：" + res.rows[i].quittingTime;
							if (res.rows[i].professorName) {
								res.rows[i].title = res.rows[i].title + "(" + res.rows[i].professorName + ")"
							}

						}
						this.dataList = res.rows[i].id;
					}
				})

			},
			changeCLass(val) {
				for (var i = 0; i < this.options1.length; i++) {
					if (this.options1[i].value == val) {
						this.title1 = this.options1[i].label
						break;
					}
				}
				this.getList()
			},

			// tab栏切换
			change(val) {
				this.getAllSign(val)
				// this.swiperCurrent = index;
				// this.getOrderList(index);
			},
			getAllSign(val) {
				let data = {
					classId: "",
					courseId: val
				}
				for (var i = 0; i < this.dataList.length; i++) {
					if (this.dataList[i].id == val) {
						data.classId = this.dataList[i].classId;
						break;
					}
				}

				getAllSign(data).then((res) => {
					
					if (res.code == 200) {
						for (var i = 0; i < res.data.noSignList.length; i++) {
							res.data.noSignList[i].status = false
						}
						
						for (var i = 0; i < res.data.signList.length; i++) {
							res.data.signList[i].status = true
						}
						this.signList = res.data.noSignList.concat(res.data.signList);
						// this.list[0].count = res.data.signList.length + '人'
						// this.list[1].count = res.data.noSignList.length + '人'
						// if (this.isAnnounce == 0) {
						// 	this.signList = res.data.signList
						// } else {
						// 	this.signList = res.data.noSignList
						// }
					}

				})
			},
			transition({
				detail: {
					dx
				}
			}) {
				this.$refs.tabs.setDx(dx);
			},
			animationfinish({
				detail: {
					current
				}
			}) {
				this.$refs.tabs.setFinishCurrent(current);
				this.swiperCurrent = current;
				this.current = current;
			}
		}
	};
</script>

<style>
	/* #ifndef H5 */
	page {
		height: 100%;
		background-color: #f2f2f2;
	}

	/* #endif */
</style>

<style lang="scss" scoped>
	.u-config-wrap {
		padding: 40rpx;
	}

	.slot-content {
		background-color: #FFFFFF;
		padding: 24rpx;

		.item-box {
			margin-bottom: 50rpx;
			display: flex;
			flex-wrap: wrap;
			justify-content: space-between;

			.item {
				border: 1px solid $u-type-primary;
				color: $u-type-primary;
				padding: 8rpx 40rpx;
				border-radius: 100rpx;
				margin-top: 30rpx;
			}

			.active {
				color: #FFFFFF;
				background-color: $u-type-primary;
			}
		}
	}
</style>